package com.penghaisoft.microwms.materialhand.web.outwarehouse.controller;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.penghaisoft.microwms.common.Constant;
import com.penghaisoft.microwms.common.data.model.RawRequisitionSn;
import com.penghaisoft.microwms.common.dto.HandResp;
import com.penghaisoft.microwms.common.dto.RawOrderOutDto;
import com.penghaisoft.microwms.common.dto.RawOrderOutSnDto;
import com.penghaisoft.microwms.common.dto.RawRequisitionMesDto;
import com.penghaisoft.microwms.common.service.IMesInterfaceService;
import com.penghaisoft.microwms.common.service.MesProperties;
import com.penghaisoft.microwms.common.wms.model.RawStorageSn;
import com.penghaisoft.microwms.materialhand.web.insidewarehouse.service.IMaterialHandInsideWhService;
import com.penghaisoft.microwms.materialhand.web.outwarehouse.service.IMaterialRequisitionService;
import com.penghaisoft.microwms.materialhand.web.outwarehouse.service.RawOrderOutService;
import com.penghaisoft.microwms.materialhand.web.outwarehouse.service.RawOrderOutSnService;

/**
 * 原材料领料出库手持服务
 * Created by 王治国 on 2018/5/31.
 */
@RestController
@RequestMapping(value = "raw/rawoutwhhand")
@Slf4j
public class RawOrderOutController {

    @Autowired
    private RawOrderOutService rawOrderOutService;

    @Autowired
    private RawOrderOutSnService rawOrderOutSnService;

    @Autowired
    private IMaterialHandInsideWhService iMaterialHandInsideWhService;
    
    @Autowired
    private IMaterialRequisitionService iMaterialRequisitionService;
    
    @Autowired
	private IMesInterfaceService mesInterfaceService;
	
	@Resource
	private MesProperties mesProperties;

    /**
     * 第一步：提单
     * 提取领料单号、合同单号需求型号、型号类型、需求数量、已扫数量、单位
     *
     * @return
     */
    @PostMapping("queryOrder")
    public HandResp queryOrderByCode(@RequestBody RawOrderOutDto rawOrderOutDto) {
        HandResp resp = new HandResp();
//        领料单类型：0：普通（PE管匹配钢管）1：返修（PE管匹配自身长度）
        List<RawOrderOutDto> list = rawOrderOutService.findOrderInfo(rawOrderOutDto);
        int sucFlag = 1;//领料单是否已经完成扫码       0：未完成 1：完成
        if (list.size() > 0) {
            for (RawOrderOutDto order : list) {
//            	0 新建 1 发货中 2发货完成 3扫码完成
                if ("0".equals(order.getRequisitionStatus()) || "1".equals(order.getRequisitionStatus()) || "3".equals(order.getRequisitionStatus())) {
                    sucFlag = 0;
                    break;
                }
            }
            
            if (sucFlag == 1) {
            	resp.setCode(Constant.FAIL);
                resp.setMsg("该领料单已经发货完成！");
                return resp;
            }
        } else {
            resp.setCode(Constant.FAIL);
            resp.setMsg("该领料单不存在！");
            return resp;
        }
        
        if (!Constant.FAIL.equals(resp.getCode())){
            resp.setCode(Constant.SUCCESS);
        }
        return resp;
    }

    /**
     * 第二步：扫条码
     *
     * @param rawOrderOutSnDto（条码、领料单号）
     * @return
     * @wzhg 1866
     */
    @PostMapping("scan")
    public HandResp scanBarcode(@RequestBody RawOrderOutSnDto rawOrderOutSnDto) {
        HandResp result = new HandResp();

        int sucFlag = 1;//领料单是否已经完成扫码       0：未完成 1：完成
        RawOrderOutDto orderOutDto = new RawOrderOutDto();
        orderOutDto.setRequisitionNo(rawOrderOutSnDto.getRequisitionNo());//领料单号
//        领料单类型：0：普通（PE管匹配钢管）1：返修（PE管匹配自身长度）
//        orderOutDto.setRequisitionType("0");
        List<RawOrderOutDto> orderOutDtos = rawOrderOutService.findOrderInfo(orderOutDto);
//        // 0.判断该领料单号是否存在 以及 是否已经扫码完成
//        if (orderOutDtos.size() > 2){
//            result.setCode(Constant.FAIL);
//            result.setMsg("领料单数据异常！");
//            return result;
//        }else 
//        if (orderOutDtos.size() > 0){
//            for (RawOrderOutDto order : orderOutDtos) {
//                if ("0".equals(order.getRequisitionStatus()) || "1".equals(order.getRequisitionStatus())) {
//                    sucFlag = 0;
//                    break;
//                }
//            }
//            if (sucFlag == 1) {
//                result.setCode(Constant.FAIL);
//                result.setMsg("该领料单已经扫码完成！");
//                return result;
//            }
//        } else {
//            result.setCode(Constant.FAIL);
//            result.setMsg("该领料单不存在！");
//            return result;
//        }
        if (orderOutDtos.size() <= 0){
            result.setCode(Constant.FAIL);
            result.setMsg("领料单号不存在！");
            return result;
        }

        // 1.判断条码是否存在，是否已扫描，是否归属合同号 库存明细表/出库明细表/ 比较两个表的合同单号和领料单号（不需要，与第二步重复）
        RawStorageSn rawStorageSn = new RawStorageSn();
        rawStorageSn.setBarcode(rawOrderOutSnDto.getBarcode());
        rawStorageSn.setActiveFlag("1");
        List<RawStorageSn> rawStorageSns = new ArrayList<RawStorageSn>();
        rawStorageSns = iMaterialHandInsideWhService.findRawStorageSnAbs(rawStorageSn);
        if(rawStorageSns.size() == 0) {
            result.setCode(Constant.FAIL);
            result.setMsg("该条码不在库存中，请核查！");
            return result;
        }else if(rawStorageSns.size() > 1){
        	result.setCode(Constant.FAIL);
            result.setMsg("库存中该条码重复！");
            return result;
        }else{
        	RawStorageSn storageSn = rawStorageSns.get(0); // 库存条码
        	
        	if("2".equals(storageSn.getBarcodeStatus())){
        		result.setCode(Constant.FAIL);
                result.setMsg("该条码已出库！");
                return result;
        	}else if ("1".equals(storageSn.getBarcodeStatus())){
                result.setCode(Constant.FAIL);
                result.setMsg("该条码已被冻结！");
                return result;
            }
        	
            orderOutDto = orderOutDtos.get(0);
            //判断条码是否归属领料单号对应的合同号
            if (!storageSn.getContractNo().equals(orderOutDto.getContractNo())){
                result.setCode(Constant.FAIL);
                result.setMsg("条码所属的合同号与该领料单号对应的合同号不一致！");
                return result;
            }

            // 对应生产钢管成品的PE管才需要配套，管件的PE不需要走配套逻辑
            if (Constant.MODEL_PE.equals(storageSn.getModelType()) && "0".equals(orderOutDto.getRequisitionType())){
                //PE管扫描
                result = rawOrderOutSnService.scanPE1(rawOrderOutSnDto, storageSn);
            }else {
                //非PE管扫描
                result = rawOrderOutSnService.scanElse(rawOrderOutSnDto, storageSn);
            }
            result.setList(rawStorageSns);
        }
        
        // 7.扫码结束
        return result;
    }
    
    /** 
     * @Title delBarcode
     * @Description 退扫条码
     * @author luoteng
     * @date 2018年7月3日:上午10:06:43
     * @param rawOrderOutSnDto
     * @return HandResp
     */
    @PostMapping("del")
    public HandResp delBarcode(@RequestBody RawOrderOutSnDto rawOrderOutSnDto) {
    	HandResp resp = new HandResp();
    	
        resp = rawOrderOutSnService.delBarCode(rawOrderOutSnDto);

        return resp;
    }

    /**
     * 第三步：拣配部分满足匹配关系，上传该部分记录至MES
     *
     * @return
     */
    @PostMapping("parts/confirm")
    public HandResp partsConfirm(@RequestBody RawOrderOutDto rawOrderOutDto) {
        HandResp resp = new HandResp();
        int flg = 0;
        int ph = 0;
        int wms = 0;
        double min = 0;
        double max = 0;
        BigDecimal realAmount  = BigDecimal.ZERO ;
        BigDecimal requireAmount = BigDecimal.ZERO ;
        //        领料单类型：0：普通（PE管匹配钢管）1：返修（PE管匹配自身长度）2；管件（PE管匹配自身长度）
        // 1.根据领料单号 查询 领料单信息
        List<RawOrderOutDto> orderOutDtos = rawOrderOutService.findOrderInfo(rawOrderOutDto);
        // 设置PE管的配套参数（与钢管差值的上限与下限）
        min = Constant.min;
        max = Constant.max;
        //TODO 2.判断 出库主表该单号下 各需求型号 待发货数量 与 需求数量是否相等，如果小于，或者大于1米，不能确认，结束。
        //判断该领料单是否已经扫码完成 ： 0 新建 1 发货中 2发货完成 3扫码完成
        if ("2".equals(orderOutDtos.get(0).getRequisitionStatus())){
            resp.setCode(Constant.FAIL);
            resp.setMsg("该领料单号已经出库完成，请勿重复确认！");
            return resp;
        }

        // 如果是PE管匹配钢管的订单
        if ("0".equals(orderOutDtos.get(0).getRequisitionType())){
            RawOrderOutDto orderOutDtoLW = new RawOrderOutDto(); // 钢管
            RawOrderOutDto orderOutDtoPE = new RawOrderOutDto(); // PE管
            if (orderOutDtos.size()==2){
                for (RawOrderOutDto orderOutDto:orderOutDtos){
                    if (Constant.MODEL_L.equals(orderOutDto.getModelType()) || Constant.MODEL_W.equals(orderOutDto.getModelType())){
                        orderOutDtoLW = orderOutDto;
                        realAmount  = orderOutDtoLW.getRealAmount() == null ? BigDecimal.ZERO :orderOutDtoLW.getRealAmount();
                        requireAmount = orderOutDtoLW.getRequireAmount() == null ? BigDecimal.ZERO :orderOutDtoLW.getRequireAmount();
//                        if (orderOutDtoLW != null){
//                            if (realAmount.compareTo(requireAmount) == -1){
//                                resp.setCode(Constant.FAIL);
//                                resp.setMsg("该领料单号下还有未扫码完成的任务！");
//                                return resp;
//                            }
//                        }

                    }else if (Constant.MODEL_PE.equals(orderOutDto.getModelType())){
                        orderOutDtoPE = orderOutDto;
                    }
                }
            }else {
                resp.setCode(Constant.FAIL);
                resp.setMsg("领料单数量有错误，请联系运维人员核查！");
                return resp;
            }
            // 2.根据领料单号 查询 领料出库明细信息，根据 原材料规格（长度）进行分组查询
            // 查询对应的钢管明细，根据长度分类统计个数，PE数要配套相应长度以及个数(参数：领料单号、合同号、型号)
            List<RawOrderOutSnDto> outSnDtosLW = rawOrderOutSnService.findInfoByPE(orderOutDtoLW);
            // 查询对应的PE管明细，根据长度分类统计个数，PE数要配套相应长度以及个数(参数：领料单号、合同号、型号)
            List<RawOrderOutSnDto> outSnDtosPE = rawOrderOutSnService.findInfoByPE2(orderOutDtoPE);
            if (outSnDtosPE.size() > outSnDtosLW.size()){
                resp.setCode(Constant.FAIL);
                resp.setMsg("有待退扫的物料！");
                return resp;
            }else if (outSnDtosPE.size() < outSnDtosLW.size()){
                resp.setCode(Constant.FAIL);
                
//                resp.setMsg("该领料单号下还有未扫码完成的任务！");
                resp.setMsg("该部分上传数据，存在钢管未匹配PE管！");
                return resp;
            }
            for (RawOrderOutSnDto lw : outSnDtosLW){
                wms = 0;
                for (RawOrderOutSnDto pe : outSnDtosPE){
                    if ( lw.getAmount().compareTo(pe.getLength()) == 0){
                        wms = 1;
                        if (lw.getCount() == pe.getCount()){
                            ph += 1;break;
                        }else if (lw.getCount() < pe.getCount()){
                            resp.setCode(Constant.FAIL);
                            resp.setMsg("有待退扫的物料！");
                            return resp;
                        }else if (lw.getCount() > pe.getCount()){
                            resp.setCode(Constant.FAIL);
//                            resp.setMsg("该领料单号下还有未扫码完成的任务！");
                            resp.setMsg("该部分上传数据，存在钢管未匹配PE管！");
                            return resp;
                        }
                    }
                }

                if (wms == 0){
                    resp.setCode(Constant.FAIL);
//                    resp.setMsg("该领料单号下还有未扫码完成的任务！");
                    resp.setMsg("该部分上传数据，存在钢管未匹配PE管！");
                    return resp;
                }

            }

            if (ph == outSnDtosLW.size()){
                flg = 1;
            }

        }
        else {
            for (RawOrderOutDto dto : orderOutDtos){
                realAmount  = dto.getRealAmount() == null ? BigDecimal.ZERO :dto.getRealAmount();
                requireAmount = dto.getRequireAmount() == null ? BigDecimal.ZERO :dto.getRequireAmount();
                if (realAmount.compareTo(requireAmount) == 1 || realAmount.compareTo(requireAmount) == 0){
                    flg += 1;
                }else{
//                    resp.setCode(Constant.FAIL);
//                    resp.setMsg("该领料单号下还有未扫码完成的任务！");
//                    return resp;
                }
            }
//            if (flg == orderOutDtos.size()){
//                flg = 1;
//            }
            flg = 1;
        }


        if (flg == 1){

            String url = mesProperties.getUrl() + "/imes-provider/productplan/follow/ordersplit/materialin";
            
            RawRequisitionSn rawRequisitionSn = new RawRequisitionSn();
            rawRequisitionSn.setRequisitionNo(rawOrderOutDto.getRequisitionNo());
//            0未传mes;1已传mes
            rawRequisitionSn.setMesStatus("0");
            rawRequisitionSn.setActiveFlag("1");
            List<RawRequisitionSn> list = iMaterialRequisitionService.queryMesNormalList(rawRequisitionSn);
            
            List<RawRequisitionMesDto> mesList = new ArrayList<RawRequisitionMesDto>();
            for(RawRequisitionSn tmp : list){
            	RawRequisitionMesDto mesOb = new RawRequisitionMesDto();
            	mesOb.setMaterialId(tmp.getBarcode());
            	mesOb.setMaterialCode(tmp.getModel());
            	mesOb.setMaterialType(tmp.getModelType());
            	mesOb.setQuantity(tmp.getAmount());
            	mesOb.setMeasureUnit(tmp.getUnit());
            	mesList.add(mesOb);
            }
            
            JSONObject ob = new JSONObject();
            ob.put("receiptNo", rawOrderOutDto.getRequisitionNo());
            ob.put("materialList", mesList);
//    		调mes新增接口
    		HandResp handResp = mesInterfaceService.publicWSResp(url, MediaType.APPLICATION_JSON_TYPE, ob.toJSONString());
    		if(handResp.getCode() != null && handResp.getCode().equals("0")){
    			resp.setCode(handResp.getCode());
    			resp.setMsg(handResp.getMsg());
    	        return resp;
    		}else{
//    			更新是否上传mes状态
    			iMaterialRequisitionService.updateMesStatus(list, rawOrderOutDto.getLoginName());
//    			 // 3.确认完成，修改发货状态（出库主表：出库完成）
//                for (RawOrderOutDto orderOutDto: orderOutDtos){
//                    rawOrderOutService.updateTwo(orderOutDto);
//                }
    		}

        }
        
        resp.setCode(Constant.SUCCESS);
        resp.setMsg("确认成功！");
        return resp;
    }
    
    /**
     * 第三步：确认 条码写入数据库
     *
     * @return
     */
    @PostMapping("confirm")
    public HandResp confirm(@RequestBody RawOrderOutDto rawOrderOutDto) {
        HandResp resp = new HandResp();
        int flg = 0;
        int ph = 0;
        int wms = 0;
        double min = 0;
        double max = 0;
        BigDecimal realAmount  = BigDecimal.ZERO ;
        BigDecimal requireAmount = BigDecimal.ZERO ;
        //        领料单类型：0：普通（PE管匹配钢管）1：返修（PE管匹配自身长度）2；管件（PE管匹配自身长度）
        // 1.根据领料单号 查询 领料单信息
        List<RawOrderOutDto> orderOutDtos = rawOrderOutService.findOrderInfo(rawOrderOutDto);
        // 设置PE管的配套参数（与钢管差值的上限与下限）
        min = Constant.min;
        max = Constant.max;
        //TODO 2.判断 出库主表该单号下 各需求型号 待发货数量 与 需求数量是否相等，如果小于，或者大于1米，不能确认，结束。
        //判断该领料单是否已经扫码完成 ： 0 新建 1 发货中 2发货完成 3扫码完成
        if ("2".equals(orderOutDtos.get(0).getRequisitionStatus())){
            resp.setCode(Constant.FAIL);
            resp.setMsg("该领料单号已经出库完成，请勿重复确认！");
            return resp;
        }

        // 如果是PE管匹配钢管的订单
        if ("0".equals(orderOutDtos.get(0).getRequisitionType())){
            RawOrderOutDto orderOutDtoLW = new RawOrderOutDto(); // 钢管
            RawOrderOutDto orderOutDtoPE = new RawOrderOutDto(); // PE管
            if (orderOutDtos.size()==2){
                for (RawOrderOutDto orderOutDto:orderOutDtos){
                    if (Constant.MODEL_L.equals(orderOutDto.getModelType()) || Constant.MODEL_W.equals(orderOutDto.getModelType())){
                        orderOutDtoLW = orderOutDto;
                        realAmount  = orderOutDtoLW.getRealAmount() == null ? BigDecimal.ZERO :orderOutDtoLW.getRealAmount();
                        requireAmount = orderOutDtoLW.getRequireAmount() == null ? BigDecimal.ZERO :orderOutDtoLW.getRequireAmount();
                        if (orderOutDtoLW != null){
                            if (realAmount.compareTo(requireAmount) == -1){
                                resp.setCode(Constant.FAIL);
                                resp.setMsg("该领料单号下还有未扫码完成的任务！");
                                return resp;
                            }
                        }

                    }else if (Constant.MODEL_PE.equals(orderOutDto.getModelType())){
                        orderOutDtoPE = orderOutDto;
                    }
                }
            }else {
                resp.setCode(Constant.FAIL);
                resp.setMsg("领料单数量有错误，请联系运维人员核查！");
                return resp;
            }
            // 2.根据领料单号 查询 领料出库明细信息，根据 原材料规格（长度）进行分组查询
            // 查询对应的钢管明细，根据长度分类统计个数，PE数要配套相应长度以及个数(参数：领料单号、合同号、型号)
            List<RawOrderOutSnDto> outSnDtosLW = rawOrderOutSnService.findInfoByPE(orderOutDtoLW);
            // 查询对应的PE管明细，根据长度分类统计个数，PE数要配套相应长度以及个数(参数：领料单号、合同号、型号)
            List<RawOrderOutSnDto> outSnDtosPE = rawOrderOutSnService.findInfoByPE2(orderOutDtoPE);
            if (outSnDtosPE.size() > outSnDtosLW.size()){
                resp.setCode(Constant.FAIL);
                resp.setMsg("有待退扫的物料！");
                return resp;
            }else if (outSnDtosPE.size() < outSnDtosLW.size()){
                resp.setCode(Constant.FAIL);
                resp.setMsg("该领料单号下还有未扫码完成的任务！");
                return resp;
            }
            for (RawOrderOutSnDto lw : outSnDtosLW){
                wms = 0;
                for (RawOrderOutSnDto pe : outSnDtosPE){
                    if ( lw.getAmount().compareTo(pe.getLength()) == 0){
                        wms = 1;
                        if (lw.getCount() == pe.getCount()){
                            ph += 1;break;
                        }else if (lw.getCount() < pe.getCount()){
                            resp.setCode(Constant.FAIL);
                            resp.setMsg("有待退扫的物料！");
                            return resp;
                        }else if (lw.getCount() > pe.getCount()){
                            resp.setCode(Constant.FAIL);
                            resp.setMsg("该领料单号下还有未扫码完成的任务！");
                            return resp;
                        }
                    }
                }

                if (wms == 0){
                    resp.setCode(Constant.FAIL);
                    resp.setMsg("该领料单号下还有未扫码完成的任务！");
                    return resp;
                }

            }

            if (ph == outSnDtosLW.size()){
                flg = 1;
            }

        }
        else {
            for (RawOrderOutDto dto : orderOutDtos){
                realAmount  = dto.getRealAmount() == null ? BigDecimal.ZERO :dto.getRealAmount();
                requireAmount = dto.getRequireAmount() == null ? BigDecimal.ZERO :dto.getRequireAmount();
                if (realAmount.compareTo(requireAmount) == 1 || realAmount.compareTo(requireAmount) == 0){
                    flg += 1;
                }else{
                    resp.setCode(Constant.FAIL);
                    resp.setMsg("该领料单号下还有未扫码完成的任务！");
                    return resp;
                }
            }
            if (flg == orderOutDtos.size()){
                flg = 1;
            }
        }


        if (flg == 1){
            RawRequisitionSn rawRequisitionSn = new RawRequisitionSn();
            rawRequisitionSn.setRequisitionNo(rawOrderOutDto.getRequisitionNo());
//          0未传mes;1已传mes
            rawRequisitionSn.setMesStatus("0");
            rawRequisitionSn.setActiveFlag("1");
            List<RawRequisitionSn> list = iMaterialRequisitionService.queryMesNormalList(rawRequisitionSn);
            
            if(list == null || list.isEmpty()){
            	// 3.确认完成，修改发货状态（出库主表：出库完成）
                for (RawOrderOutDto orderOutDto: orderOutDtos){
                    rawOrderOutService.updateTwo(orderOutDto);
                }
            }else{
            	String url = mesProperties.getUrl() + "/imes-provider/productplan/follow/ordersplit/materialin";
                
                List<RawRequisitionMesDto> mesList = new ArrayList<RawRequisitionMesDto>();
            	for(RawRequisitionSn tmp : list){
                	RawRequisitionMesDto mesOb = new RawRequisitionMesDto();
                	mesOb.setMaterialId(tmp.getBarcode());
                	mesOb.setMaterialCode(tmp.getModel());
                	mesOb.setMaterialType(tmp.getModelType());
                	mesOb.setQuantity(tmp.getAmount());
                	mesOb.setMeasureUnit(tmp.getUnit());
                	mesList.add(mesOb);
                }
                
                JSONObject ob = new JSONObject();
                ob.put("receiptNo", rawOrderOutDto.getRequisitionNo());
                ob.put("materialList", mesList);
//        		调mes新增接口
        		HandResp handResp = mesInterfaceService.publicWSResp(url, MediaType.APPLICATION_JSON_TYPE, ob.toJSONString());
        		if(handResp.getCode() != null && handResp.getCode().equals("0")){
        			resp.setCode(handResp.getCode());
        			resp.setMsg(handResp.getMsg());
        	        return resp;
        		}else{
//        			更新是否上传mes状态
        			iMaterialRequisitionService.updateMesStatus(list, rawOrderOutDto.getLoginName());
        			 // 3.确认完成，修改发货状态（出库主表：出库完成）
                    for (RawOrderOutDto orderOutDto: orderOutDtos){
                        rawOrderOutService.updateTwo(orderOutDto);
                    }
        		}
            }
        }
        
        resp.setCode(Constant.SUCCESS);
        resp.setMsg("确认成功！");
        return resp;
    }

    /**
     * 查询领料单明细信息
     *
     * @return
     */
    @PostMapping("info")
    public HandResp info(@RequestBody RawOrderOutDto rawOrderOutDto) {

        HandResp result = new HandResp();
//        领料单类型：0：普通（PE管匹配钢管）1：返修（PE管匹配自身长度） 2；管件（PE管匹配自身长度）
//        List<RawOrderOutDto> list = rawOrderOutService.findOrderInfo(rawOrderOutDto);
//        List<RawOrderOutSnDto> list = rawOrderOutService.findOrderInfoPin(rawOrderOutDto);
        List<RawOrderOutDto> list = rawOrderOutService.findOrderInfoPin1(rawOrderOutDto);
        if (list.size() == 0) {
            result.setCode(Constant.FAIL);
            result.setMsg("领料单号不存在或单据为返修单");
            return result;
        }
        result.setCode(Constant.SUCCESS);
        result.setList(list);
        return result;
    }

}